<template>
	<view class="wui-collapse"><slot></slot></view>
</template>

<script>
export default {
	name: 'w-collapse',
	props: {
		value: {
			type: [Array, String]
		}
	},
	watch: {
		value: {
			handler(val) {
				this.$nextTick(() => {
					this.deepSetValue();
				});
			},
			immediate: true
		}
	},
	methods:{
		changeValue(val){
			this.$emit('input',val)
		},
		deepSetValue() {
			this.$wuiUtils.queryChilds.call(this, 'w-collapseItem', child => {
				if(this.value instanceof Array){
					child.setValueArr(this.value);
				}else{
					child.setValue(this.value);
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>

</style>
